import orgCtrl from '../ts/controller'
export const locallogin = () => {
  const loginStr = uni.getStorageSync('LoginParams')
  if (loginStr) {
    const data = JSON.parse(loginStr)
    const loginParams = {
      account: data.account,
      password: data.pwd,
      dynamicCode: '',
      dynamicId: ''
    }
    setTimeout(async () => {
      const res = await orgCtrl.auth.login(loginParams)
      if (res.code === 200) {
        uni.reLaunch({
          url: '/pages/home/home'
        })
        uni.setStorageSync(
          'LoginParams',
          JSON.stringify({
            account: loginParams.account,
            pwd: loginParams.password
          })
        )
      } else {
        uni.reLaunch({ url: '/pages/auth/login?isLogin=1' })
      }
    }, 1000)
  } else {
    uni.reLaunch({ url: '/pages/auth/login?isLogin=1' })
  }
}
